using System.Linq;

namespace DistanceLearning.Models
{
    partial class JournalContext
    {
        partial void InsertSubject(Subject instance)
        {
            if (!Subjects.Contains(instance))
                ExecuteDynamicInsert(instance);
        }
        partial void InsertJournal(Journal instance)
        {
            if (!Journals.Contains(instance))
                ExecuteDynamicInsert(instance);
        }

        partial void UpdateJournal(Journal instance)
        {
            ExecuteDynamicUpdate(instance);
        }

        partial void InsertTeacherSubject(TeacherSubject instance)
        {
            if (!TeacherSubjects.Contains(instance))
                ExecuteDynamicInsert(instance);
        }

        partial void InsertConcreteLesson(ConcreteLesson instance)
        {
            if (!ConcreteLessons.Contains(instance))
                ExecuteDynamicInsert(instance);
        }

        partial void InsertConcreteLessonPupilDetails(ConcreteLessonPupilDetails instance)
        {
            if (!ConcreteLessonPupilDetails.Contains(instance))
                ExecuteDynamicInsert(instance);
        }

        partial void InsertParentChild(ParentChild instance)
        {
            if(!ParentChilds.Contains(instance))
                ExecuteDynamicInsert(instance);
        }
    }

    public partial class Teacher
    {
        public override string ToString()
        {
            return string.Format("{0} {1}. {2}.", UserDetails.LastName, UserDetails.FirstName[0], UserDetails.PatronymicName[0]);
        }
    }

    public partial class Parent
    {
        public override string ToString()
        {
            return string.Format("{0} {1}. {2}.", UserDetails.LastName, UserDetails.FirstName[0], UserDetails.PatronymicName[0]);
        }

        public string DisplayText
        {
            get { return ToString(); }
        }
    }
}